Skip to content

ASTC decoding part 2: High dynamic range support and reference testing#47

Draft
Erik-White wants to merge 12 commits into
SixLabors:mainfrom
Erik-White:astc-decoding-hdr
Draft

ASTC decoding part 2: High dynamic range support and reference testing#47
Erik-White wants to merge 12 commits into
SixLabors:mainfrom
Erik-White:astc-decoding-hdr

Conversation

@Erik-White
Copy link
Copy Markdown
Contributor

@Erik-White Erik-White commented May 17, 2026

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

The second part of ASTC (Adaptive scalable texture compression) decoding. ASTC is used with KTX containers to compress texture data.
This extends the ASTC decoder to add HDR support. It also adds tests that compare output with the ARM C++ reference decoder.

Prerequisites

To follow

  • Benchmarks
  • Fuzz testing

Limitations

  • No support for 3D ASTC block types (4x4x4 etc)
  • No encoding

Intentionally omitted

  • Float output for HDR (doesn't appear to be useful for ImageSharp.Textures, but would be trivial to implement)
  • Swizzle remapping (also not useful for ImageSharp.Textures, can be handled downstream)
  • sRGB containers decode to raw UNORM8 (conversion is handled downstream)

Test data

Everything used is either created by myself, or sourced from
https://github.com/KhronosGroup/KTX-Software (Apache 2.0 license)
https://github.com/KhronosGroup/KTX-Software-CTS (Apache 2.0 license)
https://github.com/ARM-software/astc-encoder (Apache-2.0 license)

Performance

This implementation compares very favourably to the ARM C++ implementation. Single shot benchmarks show 3-4 faster on this small test set:

| Method         | Categories | Mean      | Error     | StdDev    | Ratio | RatioSD | Allocated | Alloc Ratio |
|--------------- |----------- |----------:|----------:|----------:|------:|--------:|----------:|------------:|
| Reference_Hdr  | HDR        |  7.118 ms | 0.1379 ms | 0.1588 ms |  1.00 |    0.03 |     460 B |        1.00 |
| ImageSharp_Hdr | HDR        |  1.932 ms | 0.0113 ms | 0.0100 ms |  0.27 |    0.01 |     288 B |        0.63 |

...however this includes the allocation overhead of the ARM decoder. Re-using the same decoder context in the ARM decoder shows a probably more realistic comparison:

| Method         | Categories | Mean       | Error    | StdDev   | Ratio | RatioSD | Allocated | Alloc Ratio |
|--------------- |----------- |-----------:|---------:|---------:|------:|--------:|----------:|------------:|
| Reference_Hdr  | HDR        |   943.3 us | 11.18 us | 10.46 us |  1.00 |    0.02 |         - |          NA |
| ImageSharp_Hdr | HDR        | 1,927.2 us | 10.61 us |  9.92 us |  2.04 |    0.02 |     288 B |          NA |

@Erik-White Erik-White force-pushed the astc-decoding-hdr branch 2 times, most recently from 90004e3 to dff4e27 Compare May 17, 2026 14:27
@Erik-White Erik-White force-pushed the astc-decoding-hdr branch from dff4e27 to 26bd2fa Compare May 17, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant